package com.cskaoyan.service.wx;

import com.cskaoyan.bean.Feedback;
import com.cskaoyan.bean.User;
import com.cskaoyan.bean.wx.WxFeedbackSubmitBO;
import com.cskaoyan.mapper.FeedbackMapper;
import com.cskaoyan.mapper.UserMapper;
import com.cskaoyan.utils.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class WxFeedbackServiceImpl implements WxFeedbackService {

    @Autowired
    FeedbackMapper feedbackMapper;
    @Autowired
    UserMapper userMapper;

    @Override
    public void insertFeedbackSubmit(WxFeedbackSubmitBO wxFeedbackSubmitBO) {
        //获得userId
        Integer id = IdUtils.getId();
        User user = userMapper.selectByPrimaryKey(id);

        Feedback feedback = new Feedback();
        feedback.setUsername(user.getUsername());
        feedback.setUserId(id);
        feedback.setMobile(wxFeedbackSubmitBO.getMobile());
        feedback.setAddTime(new Date());
        feedback.setContent(wxFeedbackSubmitBO.getContent());
        feedback.setFeedType(wxFeedbackSubmitBO.getFeedType());
        feedback.setHasPicture(wxFeedbackSubmitBO.isHasPicture());
        feedback.setPicUrls(wxFeedbackSubmitBO.getPicUrls());
        feedback.setUpdateTime(new Date());
        int i = feedbackMapper.insertSelective(feedback);
    }
}
